//
//  SISSBlackListViewController.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/3.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSBlackListViewController.h"
#import "SISSNetworkingManager+Mine.h"

@interface SISSBlackListViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
@property (weak, nonatomic) IBOutlet UITextField *IDCardNumberTextField;
@property (weak, nonatomic) IBOutlet UIButton *queryButton;

@end

@implementation SISSBlackListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}



/**
 查询按钮点击事件
 */
- (IBAction)queryButtonClickAction:(UIButton *)sender {
    
    if (self.nameTextField.text.length == 0) {
        [SISSTools showSVErrorTitle:@"请输入姓名" andTime:2 andColor:YES];
        return;
    }
    if (self.IDCardNumberTextField.text.length == 0) {
        [SISSTools showSVErrorTitle:@"请输入身份证号码" andTime:2 andColor:YES];
        return;
    }
    if (![NSString checkUserIdCard:self.IDCardNumberTextField.text]) {
        [SISSTools showSVErrorTitle:@"请输入正确的身份证号码" andTime:2 andColor:YES];
        return;
    }
    

    NSLog(@"%@ \n %@",self.nameTextField.text,self.IDCardNumberTextField.text);
    
    [kNetworkManager requestBackListWithIdNO:self.IDCardNumberTextField.text success:^(id responseObject) {
        
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
    
            NSLog(@"%@",responseObject[@"data"]);
            NSDictionary *dictData = responseObject[@"data"];
            if (![PublicUtil isBlankDictionary:dictData]) {
                [self alertActionAlertWithTitle:@"查询结果" message:dictData[@"reasonIn"]];
            } else {
                [self alertActionAlertWithTitle:@"查询结果" message:@"未查询到黑名单记录"];
            }
            return;
        }
        
    } failed:^(NSError *error) {
        
        NSLog(@"%@",error);
    }];
}

@end
